package com.order;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.PrintWriter;

public class loginServlet  extends HttpServlet {

    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        response.setContentType("text/html;charset=UTF-8");
        request.setCharacterEncoding("UTF-8");
        response.setCharacterEncoding("UTF-8");

        /* 设置响应头允许ajax跨域访问 */
        response.setHeader("Access-Control-Allow-Origin", "*");
        /* 星号表示所有的异域请求都可以接受， */
        response.setHeader("Access-Control-Allow-Methods", "GET,POST");

        String name=request.getParameter("name");
        System.out.println(name);

        PrintWriter out=response.getWriter();

        out.print("<!DOCTYPE html>"+
                "<html>"+
                "<head>"+
                "<title>"+
                    "项目测试"+
                "</title>"+
                "</head>"+
                "<body>"+
                    name+
                "</body>"+
                "</html>"
        );

    }
}
